<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="Cache-Control" content="no-cache,must-revalidate">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta name="format-detection" content="telephone=no, address=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black-translucent" name="apple-mobile-web-app-status-bar-style">
    <title></title>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
    <link href="https://cdn.bootcss.com/jquery-mobile/1.4.5/jquery.mobile.theme.css" rel="stylesheet">

    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>



    <script type="text/javascript">

        $(function () {
            //加载下拉框数据
            loadMeetingType();
        })
        //加载下拉框数据
        function loadMeetingType(){

            $.ajax({
                type:"get",
                url:"/meetingType/list",
                success:function(objs){

                    var appendHtml="<option value='0'>请选择</option>";

                    if(objs.code=="2000"){
                       var obj=  objs.data;
                       for(var i=0;i<obj.length;i++){
                           var id=obj[i].id;
                           var name=obj[i].name;
                        appendHtml+="<option value='"+id+"'>"+name+"</option>";

                       }
                        $("#tid").append(appendHtml);

                    }


                }

            });

        }


        function showPubDiv() {
            $("#two_line").css("border-top", "5px solid #4E90C7");
            //$("#two_tab").css("color","#777777");
            $("#one_line").css("border-top", "5px solid white");
            //$("#one_tab").css("color","white");
            $("#two").css("display", "none");
            $("#one").css("display", "block");
        }

        function showMyMeetings() {

            $("#two_line").css("border-top", "5px solid white");
            $("#one_line").css("border-top", "5px solid #4E90C7");

            $("#one").css("display", "none");
            $("#two").css("display", "block");

            $("#two").empty();


            var uid=$("#uid").val();
            $.ajax({
                type:"get",
                url:"/meetingPub/listByUid",
                data:{"uid":uid},
                success:function(objs){
                    if(objs.code=="2003"){
                        //数据为空
                    }else if(objs.code=="2000"){
                        var data=objs.data;

                        var mname="";
                        var remark="";
                        var dateCurr="";
                        var appendHtml = "<font style='padding: 10px 10px 10px 15px;display: block;color: #777777;'>您共发布了"+data.length+"场会议</font>";

                        for(var i=0;i<data.length;i++){

                            mname=data[i].title;
                            remark=data[i].meetingType.name;
                            dateCurr=data[i].pcode;
                            var pid=data[i].id;
                            appendHtml += "<div style='width: 100%;background-color: white;margin-top: -3px;padding:10px 10px 10px 15px;display: inline-block;'>" +
                                "<div style='width: 70%;float: left;' onclick='showMeetingInfo(\"" + 1 + "\");'>" +
                                "<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;font-size:18px;'>" +
                                mname + "</div>" +
                                "<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;color: #777777;font-size:16px;padding-top:1px'>" +
                                remark + " / " + dateCurr + "</div></div>" +
                                "<div style='width: 30%;float: right;'>" +
                                "<button class='able-btn' onclick='chooseGrabListToPage(\""+pid+"\")' >选择讲者</button></div></div>";

                        }
                        $("#two").append(appendHtml);

                    }
                }


            });


        }

        function chooseGrabListToPage(pid){
            //选择讲者
            window.location.href="/meetingPub/chooseGrabListToPage?pid="+pid;

        }
        //会议发布
        function subMeetingPub(){
            //非空校验
            var title=$("#title").val();
            if(title==""){
                alert("会议主题不能为空");
                return ;
            }
            var pTime=$("#pTime").val();

            if(pTime==""){
                alert("会议召开时间请填写完整");
                return ;
            }

            var tid=$("#tid").val();

            if(tid=="0"){
                alert("请选择课题类别");
                return ;
            }

            //进行ajax添加功能
            var objData=$("#pubForm").serialize();
            $.ajax({
                type:"post",
                url:"/meetingPub/addMeetingPub",
                data:objData,
                success:function(objs){
                    if(objs.code=="2000"){
                        alert("会议发布成功");

                        $("#title").val("");
                        $("#pTime").val("");
                        $("#tid").find("option[value='0']").attr("selected",true);
                    }

                }
            });
        }

    </script>
</head>
<body>

<div data-role="page" id="pageDetail">
    <div style="padding:0px;background-color: #4E90C7;width: 100%;height:40px;line-height:40px;font-size:18px;text-align: center;cursor: pointer;" data-role="none">
        <div style="width: 50%;float: left;color: white;" onclick="showPubDiv();" id="one_tab">
            发布
            <div style="border-right: 1px solid white;float: right;margin-top: 10px;height: 20px;"></div>
        </div>
        <div style="width: 50%;float: left;color: white;" onclick="showMyMeetings();" id="two_tab">我的会议</div>
        <div style="border-top:5px solid white;width: 50%;float: left;" id="one_line"></div>
        <div style="border-top:5px solid #4E90C7;width: 50%;float: left;" id="two_line"></div>
    </div>
    <div id="one" class="ui-body-d ui-content" style="padding:0;display: block;width: 100%;">
        <font style="padding:10px 10px 10px 15px;display: block;color: #777777;">请填写会议相关信息</font>
        <div style="width: 100%;background-color: white;padding:10px 0 10px 0;">

            <form id="pubForm" method="post">
                <input type="hidden" id="uid" name="uid" th:value="${uid}">
                <div style="padding-right:15px;padding-left:15px">
                    <label for="title" class="font-label">会议名称:</label>
                    <input name="title" id="title" placeholder="请输入会议名称" ></input>
                </div>
                <div  style="padding-right:15px;padding-left:15px">
                    <label for="pTime" class="font-label">会议日期</label>
                    <input type="datetime-local" name="pTime" id="pTime" />
                </div>
                <div style="padding-right:15px;padding-left:15px">
                    <label for="tid" class="font-label">类别：</label>
                    <select name="tid" id="tid">

                    </select>
                </div>


                <div style="padding-right:15px;padding-left:15px">
                    <label for="zone" class="font-label">讲者区域：</label>
                    <select name="zone" id="zone">
                        <option value="全国">全国</option>
                        <option value="东区">东区</option>
                        <option value="西区">西区</option>
                        <option value="南区">南区</option>
                        <option value="北区">北区</option>
                    </select>
                </div>

                <div style="padding-right:15px;padding-left:15px">
                    <label for="remark" class="font-label">备注(选填，100字以内)</label>
                    <textarea name="remark" id="remark" placeholder="请输入会议备注" maxlength="100" class="font-blue input-lightblue" style="box-shadow: none;"></textarea>
                </div>
                <div style="padding-right:15px;padding-left:15px">
                    <input type="button" value="发布会议"  onclick="subMeetingPub()" id="btnId" />
                </div>
            </form>
        </div>
    </div>





    <div id="two" class="ui-body-d ui-content" style="padding: 0;display: none;width: 100%;">

    </div>
</body>

</html>